package com.example.administrator.yanfoxconn.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.yanfoxconn.R;
import com.example.administrator.yanfoxconn.bean.AQ110Message;
import com.example.administrator.yanfoxconn.bean.ActivityMsg;
import com.example.administrator.yanfoxconn.bean.LWInfo;

import java.util.List;

/**
 * Created by S1007989 on 2021/05/21
 * Description：活動查詢列表
 */
public class ActListAdapter extends BaseAdapter {
    public Context mContext;
    private List<ActivityMsg> lists;
    private List<LWInfo> lwInfos;
    private String from="";

    public ActListAdapter(Context context, List<ActivityMsg> lists) {
        this.mContext = context;
        this.lists = lists;
    }
    public ActListAdapter(Context context, List<LWInfo> lwInfos,String from) {
        this.mContext = context;
        this.lwInfos = lwInfos;
        this.from = from;
    }

    @Override
    public int getCount() {
        if (from.equals("")){
        return lists.size();
        }else{
            return lwInfos.size();
        }
    }

    @Override
    public Object getItem(int position) {
        if (from.equals("")){
        return lists.get(position);
        }else{
            return lwInfos.get(position);
        }
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_act_list, null);
            holder.tvNum = (TextView)convertView.findViewById(R.id.tv_num);
            holder.tvCpc = (TextView)convertView.findViewById(R.id.tv_cpc);
            holder.tvDate = (TextView)convertView.findViewById(R.id.tv_date);
            holder.tvPosition = (TextView)convertView.findViewById(R.id.tv_position);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (from.equals("")) {
            holder.tvNum.setText("" + (position + 1));
            holder.tvCpc.setText(lists.get(position).getAct_name());
            holder.tvDate.setText(lists.get(position).getAct_type());
            holder.tvPosition.setText(lists.get(position).getCreate_name());
        }else{
             
        }
        return convertView;
        }

    private class ViewHolder{
        public TextView tvNum,tvCpc,tvDate,tvPosition,tvContent,tvPhone;
        LinearLayout  ll110;
    }

}
